package com.ssy.lingxi.product.controller.pc;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.ssy.lingxi.common.constant.CommonConstant;
import com.ssy.lingxi.common.constant.Constants;
import com.ssy.lingxi.common.constant.manage.ShopTypeEnum;
import com.ssy.lingxi.common.constant.product.CommodityStatusEnum;
import com.ssy.lingxi.common.constant.product.PriceTypeEnum;
import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.exception.BusinessException;
import com.ssy.lingxi.common.model.dto.UserLoginCacheDTO;
import com.ssy.lingxi.common.model.vo.PageVO;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.ResponseCode;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.component.redis.service.IRedisStringUtils;
import com.ssy.lingxi.product.api.model.request.SimpleIdListRequest;
import com.ssy.lingxi.product.api.model.request.SimpleIdRequest;
import com.ssy.lingxi.product.api.model.request.channelCommodity.*;
import com.ssy.lingxi.product.api.model.request.commodity.CommodityQueryRequest;
import com.ssy.lingxi.product.api.model.response.SimpleBrandResponse;
import com.ssy.lingxi.product.api.model.response.SimpleCustomerCategoryResponse;
import com.ssy.lingxi.product.api.model.response.channelCommodity.ChannelCommodityDetailResponse;
import com.ssy.lingxi.product.api.model.response.channelCommodity.ChannelCommodityMemberResponse;
import com.ssy.lingxi.product.api.model.response.channelCommodity.CommodityResponse;
import com.ssy.lingxi.product.api.model.response.commodity.CommodityShopResponse;
import com.ssy.lingxi.product.api.model.response.commodity.UnitPriceAndPicResponse;
import com.ssy.lingxi.product.common.enums.CommoditySourceEnum;
import com.ssy.lingxi.product.entity.channelCommodity.ChannelCommodity;
import com.ssy.lingxi.product.entity.channelCommodity.ChannelCommodityMember;
import com.ssy.lingxi.product.entity.channelCommodity.ChannelCommodityShop;
import com.ssy.lingxi.product.entity.channelCommodity.ChannelCommodityUnitPricePic;
import com.ssy.lingxi.product.entity.commodity.Commodity;
import com.ssy.lingxi.product.entity.commodity.CommodityUnitPriceAndPic;
import com.ssy.lingxi.product.service.IChannelCommodityService;
import com.ssy.lingxi.product.service.ICommodityService;
import org.apache.commons.lang.StringUtils;
import org.modelmapper.TypeToken;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @menu: 渠道商品
 * 渠道商品管理类
 * @author jw.chen
 * @version 2.0.0
 * @date 2020/8/2
 */
@RestController
@RequestMapping("/product/channelCommodity")
public class ChannelCommodityController extends BaseController {

    @Resource
    private ICommodityService commodityService;

    @Resource
    private IChannelCommodityService channelCommodityService;

    @Resource
    private IRedisStringUtils redisStringUtils;

    /**
     * 查询渠道商品列表
     * @param pageVO 分页实体
     * @param channelCommodityQueryRequest 查询条件实体
     * @return
     */
    @RequestMapping(value = "/getChannelCommodityList", method = RequestMethod.GET)
    public Wrapper<PageData<ChannelCommodityMemberResponse>> getChannelCommodityList(PageVO pageVO, ChannelCommodityQueryRequest channelCommodityQueryRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser();
        Long memberId = sysUser.getMemberId();
        Long memberRoleId = sysUser.getMemberRoleId();
        channelCommodityQueryRequest.setChannelMemberId(memberId);
        channelCommodityQueryRequest.setChannelMemberRoleId(memberRoleId);

        Page<ChannelCommodityMember> result = channelCommodityService.getChannelCommodityMemberList(pageVO, channelCommodityQueryRequest);
        List<ChannelCommodityMemberResponse> resultList = this.modelMapper.map(result.getContent(), new TypeToken<List<ChannelCommodityMemberResponse>>(){}.getType());
        return Wrapper.success(new PageData<>(result.getTotalElements(), resultList));
    }

    /**
     * 查询渠道商品详情
     * @param id 渠道商品id
     * @return
     */
    @RequestMapping(value = "/getChannelCommodity", method = RequestMethod.GET)
    public Wrapper<ChannelCommodityDetailResponse> getChannelCommodity(@RequestParam Long id) {
        ChannelCommodityMember channelCommodityMember = channelCommodityService.getChannelCommodityMember(id);
        if(channelCommodityMember != null){
            ChannelCommodityDetailResponse channelCommodityDetailResponse = this.modelMapper.map(channelCommodityMember, ChannelCommodityDetailResponse.class);
            //查询该商品上架的商城
            List<ChannelCommodityShop> shopList = channelCommodityMember.getShopList();
            if(shopList != null && shopList.size() > 0){
                String[] fields = shopList.stream().map(shop -> String.valueOf(shop.getShopId())).toArray(String[]::new);
                List<String> list = redisStringUtils.hMGet(Constants.REDIS_KEY_SHOP, fields, Constants.REDIS_PLATFORM_MANAGE_INDEX);
                List<CommodityShopResponse> resultList = list.stream().map(value -> {
                    if (StringUtils.isNotEmpty(value)) {
                        JSONObject jsonObject = JSONUtil.parseObj(value);
                        Long shopId = jsonObject.getLong("id");
                        Integer type = jsonObject.getInt("type");
                        Integer environment = jsonObject.getInt("environment");
                        String name = jsonObject.getStr("name");
                        String logoUrl = jsonObject.getStr("logoUrl");
                        CommodityShopResponse shopResponse = new CommodityShopResponse();
                        shopResponse.setShopId(shopId);
                        shopResponse.setType(type);
                        shopResponse.setEnvironment(environment);
                        shopResponse.setIsCheck(true);
                        shopResponse.setName(name);
                        shopResponse.setLogoUrl(logoUrl);
                        return shopResponse;
                    } else {
                        return null;
                    }
                }).filter(Objects::nonNull).collect(Collectors.toList());
                channelCommodityDetailResponse.setCommodityShopList(resultList);
            }
            return Wrapper.success(channelCommodityDetailResponse);
        }
        return Wrapper.success(null);
    }

    /**
     * 查询上级渠道/渠道自有商品列表
     * @param pageVO 分页实体
     * @param channelQueryRequest 查询条件实体
     * @return
     */
    @RequestMapping(value = "/getCommodityList", method = RequestMethod.GET)
    public Wrapper<PageData<CommodityResponse>> getCommodityList(PageVO pageVO, ChannelQueryRequest channelQueryRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser();
        Long memberId = sysUser.getMemberId();
        Long memberRoleId = sysUser.getMemberRoleId();
        //判断是查询上级渠道或者渠道自有商品
        Integer source = channelQueryRequest.getSource();
        if(CommoditySourceEnum.Parent_Channel.getCode().equals(source)){
            ChannelCommodityQueryRequest channelCommodityQueryRequest = this.modelMapper.map(channelQueryRequest, ChannelCommodityQueryRequest.class);
            Long parentMemberId = channelQueryRequest.getParentMemberId();
            if(parentMemberId != null && parentMemberId > 0){
                List<Long> upperChannelMemberIds = new ArrayList<>();
                upperChannelMemberIds.add(parentMemberId);
                channelCommodityQueryRequest.setMemberIdList(upperChannelMemberIds);
            }else{
                List<Long> upperChannelMemberIds = sysUser.getUpperChannelMemberIds();
                if(upperChannelMemberIds != null && !upperChannelMemberIds.isEmpty()){
                    channelCommodityQueryRequest.setMemberIdList(upperChannelMemberIds);
                }else{
                    return Wrapper.success(new PageData<>(0L, new ArrayList<>()));
                }
            }

            channelCommodityQueryRequest.setChildMemberId(memberId);
            channelCommodityQueryRequest.setChildMemberRoleId(memberRoleId);
            channelCommodityQueryRequest.setSource(null);
            List<Integer> statusList = new ArrayList<>();
            statusList.add(CommodityStatusEnum.On_Shelf.getCode());
            channelCommodityQueryRequest.setStatusList(statusList);
            Page<ChannelCommodityMember> result = channelCommodityService.getChannelCommodityMemberList(pageVO, channelCommodityQueryRequest);
            List<ChannelCommodityMember> channelCommodityMemberList = result.getContent();
            List<CommodityResponse> resultList = channelCommodityMemberList.stream().map(channelCommodityMember -> {
                ChannelCommodity channelCommodity = channelCommodityMember.getChannelCommodity();
                Commodity commodity = channelCommodity.getCommodity();
                CommodityResponse commodityResponse = new CommodityResponse();
                commodityResponse.setId(channelCommodityMember.getId());
                commodityResponse.setCode(commodity.getCode());
                commodityResponse.setName(commodity.getName());
                if(commodity.getBrand() != null){
                    commodityResponse.setBrand(this.modelMapper.map(commodity.getBrand(), SimpleBrandResponse.class));
                }
                commodityResponse.setCustomerCategory(this.modelMapper.map(commodity.getCustomerCategory(), SimpleCustomerCategoryResponse.class));
                commodityResponse.setMemberId(channelCommodity.getMemberId());
                commodityResponse.setMemberName(channelCommodity.getMemberName());
                commodityResponse.setPriceType(commodity.getPriceType());
                commodityResponse.setStatus(channelCommodityMember.getStatus());
                commodityResponse.setUnitName(commodity.getUnitName());
                return commodityResponse;
            }).collect(Collectors.toList());
            return Wrapper.success(new PageData<>(result.getTotalElements(), resultList));
        }else if(CommoditySourceEnum.Channel_Sel.getCode().equals(source)){
            //封装查询参数
            CommodityQueryRequest commodityQueryRequest = new CommodityQueryRequest();
            commodityQueryRequest.setName(channelQueryRequest.getName());
            commodityQueryRequest.setBrandName(channelQueryRequest.getBrandName());
            commodityQueryRequest.setCustomerCategoryName(channelQueryRequest.getCustomerCategoryName());
            commodityQueryRequest.setMemberId(sysUser.getMemberId());
            List<Integer> statusList = new ArrayList<>();
            statusList.add(CommodityStatusEnum.Pass.getCode());
            statusList.add(CommodityStatusEnum.On_Shelf.getCode());
            statusList.add(CommodityStatusEnum.Off_Shelf.getCode());
            commodityQueryRequest.setStatusList(statusList);
            List<Integer> priceTypeList = new ArrayList<>();
            priceTypeList.add(PriceTypeEnum.Cash.getCode());
            priceTypeList.add(PriceTypeEnum.Score.getCode());
            commodityQueryRequest.setPriceTypeList(priceTypeList);

            Page<Commodity> result = commodityService.getCommodityList(pageVO, commodityQueryRequest);
            List<CommodityResponse> resultList = this.modelMapper.map(result.getContent(), new TypeToken<List<CommodityResponse>>(){}.getType());
            return Wrapper.success(new PageData<>(result.getTotalElements(), resultList));
        }
        return Wrapper.success(new PageData<>(0L, new ArrayList<>()));
    }

    /**
     * 查询商品价格信息--新增
     * @param id 会员商品id
     * @param source 1-上级渠道商品; 2-渠道自有商品;
     * @return
     */
    @RequestMapping(value = "/getCommodityUnitPrice", method = RequestMethod.GET)
    public Wrapper<List<UnitPriceAndPicResponse>> getCommodityUnitPrice(@RequestParam Long id, @RequestParam Integer source) {
        if(CommoditySourceEnum.Parent_Channel.getCode().equals(source)){
            ChannelCommodityMember channelCommodityMember = channelCommodityService.getChannelCommodityMember(id);
            if(channelCommodityMember != null) {
                List<ChannelCommodityUnitPricePic> channelCommodityUnitPriceAndPicList = channelCommodityMember.getUnitPriceAndPicList();
                List<UnitPriceAndPicResponse> responseList = channelCommodityUnitPriceAndPicList.stream().map(channelCommodityUnitPricePic -> {
                    UnitPriceAndPicResponse unitPriceAndPicResponse = BeanUtil.copyProperties(channelCommodityUnitPricePic, UnitPriceAndPicResponse.class);
                    unitPriceAndPicResponse.setId(channelCommodityUnitPricePic.getCommodityUnitPriceAndPicId());
                    return unitPriceAndPicResponse;
                }).collect(Collectors.toList());
                return Wrapper.success(responseList);
            }
        }else if(CommoditySourceEnum.Channel_Sel.getCode().equals(source)){
            Commodity commodity = commodityService.getCommodity(id);
            if(commodity != null){
                List<CommodityUnitPriceAndPic> unitPriceAndPicList = commodity.getUnitPriceAndPicList();
                List<UnitPriceAndPicResponse> responseList = this.modelMapper.map(unitPriceAndPicList, new TypeToken<List<UnitPriceAndPicResponse>>() {}.getType());
                return Wrapper.success(responseList);
            }
        }
        return Wrapper.success(new ArrayList<>());
    }

    /**
     * 查询商品价格信息--修改
     * @param channelCommodityUnitPriceRequest 渠道会员商品
     * @return
     */
    @RequestMapping(value = "/getCommodityUnitPriceByChannel", method = RequestMethod.POST)
    public Wrapper<List<UnitPriceAndPicResponse>> getCommodityUnitPriceByChannel(@RequestBody ChannelCommodityUnitPriceRequest channelCommodityUnitPriceRequest) {
        Long id = channelCommodityUnitPriceRequest.getId();
        List<Long> idList = channelCommodityUnitPriceRequest.getIdList();
        ChannelCommodityMember channelCommodityMember = channelCommodityService.getChannelCommodityMember(id);
        if(channelCommodityMember != null){
            List<ChannelCommodityUnitPricePic> channelCommodityUnitPriceAndPicList = channelCommodityMember.getUnitPriceAndPicList();
            Integer source = channelCommodityMember.getChannelCommodity().getSource();
            if(CommoditySourceEnum.Parent_Channel.getCode().equals(source)){
                List<ChannelCommodityUnitPricePic> commodityUnitPriceAndPicList = channelCommodityMember.getChannelCommodity().getParentChannelCommodityMember().getUnitPriceAndPicList();
                List<UnitPriceAndPicResponse> resultList = commodityUnitPriceAndPicList.stream().map(commodityUnitPriceAndPic -> {
                    UnitPriceAndPicResponse unitPriceAndPicResponse = new UnitPriceAndPicResponse();
                    Long commodityUnitPriceAndPicId = commodityUnitPriceAndPic.getCommodityUnitPriceAndPicId();
                    List<Long> existIdList = channelCommodityUnitPriceAndPicList.stream().map(ChannelCommodityUnitPricePic::getCommodityUnitPriceAndPicId).collect(Collectors.toList());
                    if(!existIdList.contains(commodityUnitPriceAndPicId) && !idList.contains(commodityUnitPriceAndPicId)){
                        BeanUtil.copyProperties(commodityUnitPriceAndPic, unitPriceAndPicResponse);
                        unitPriceAndPicResponse.setId(commodityUnitPriceAndPicId);
                        return unitPriceAndPicResponse;
                    }else{
                        return null;
                    }
                }).filter(Objects::nonNull).collect(Collectors.toList());
                return Wrapper.success(resultList);
            }else if(CommoditySourceEnum.Channel_Sel.getCode().equals(source)){
                List<CommodityUnitPriceAndPic> commodityUnitPriceAndPicList = channelCommodityMember.getChannelCommodity().getCommodity().getUnitPriceAndPicList();
                List<UnitPriceAndPicResponse> resultList = commodityUnitPriceAndPicList.stream().map(commodityUnitPriceAndPic -> {
                    UnitPriceAndPicResponse unitPriceAndPicResponse = new UnitPriceAndPicResponse();
                    Long commodityUnitPriceAndPicId = commodityUnitPriceAndPic.getId();
                    List<Long> existIdList = channelCommodityUnitPriceAndPicList.stream().map(ChannelCommodityUnitPricePic::getCommodityUnitPriceAndPicId).collect(Collectors.toList());
                    if(!existIdList.contains(commodityUnitPriceAndPicId) && !idList.contains(commodityUnitPriceAndPicId)){
                        BeanUtil.copyProperties(commodityUnitPriceAndPic, unitPriceAndPicResponse);
                        return unitPriceAndPicResponse;
                    }else{
                        return null;
                    }
                }).filter(Objects::nonNull).collect(Collectors.toList());
                return Wrapper.success(resultList);
            }
        }
        return Wrapper.success(new ArrayList<>());
    }

    /**
     * 渠道商品发布
     * @param channelCommodityRequest 商品实体
     * @return
     */
    @RequestMapping(value = "/saveChannelCommodity", method = RequestMethod.POST)
    public Wrapper<Long> saveChannelCommodity(@RequestBody ChannelCommodityRequest channelCommodityRequest){
        UserLoginCacheDTO sysUser = this.getSysUser();
        return Wrapper.success(channelCommodityService.saveChannelCommodity(sysUser, channelCommodityRequest));
    }

    /**
     * 渠道商品修改
     * @param channelCommodityUpdateRequest
     * @return
     */
    @RequestMapping(value = "/updatePriceChannelCommodity", method = RequestMethod.POST)
    public Wrapper<Long> updatePriceChannelCommodity(@RequestBody ChannelCommodityUpdateRequest channelCommodityUpdateRequest){
        UserLoginCacheDTO sysUser = this.getSysUser();
        return Wrapper.success(channelCommodityService.updatePriceChannelCommodity(sysUser, channelCommodityUpdateRequest));
    }

    /**
     * 批量删除渠道商品
     * @param simpleIdListRequest
     * @return
     */
    @RequestMapping(value = "deleteBatchChannelCommodity", method = RequestMethod.POST)
    public Wrapper<String> deleteBatchChannelCommodity(@RequestBody SimpleIdListRequest simpleIdListRequest){
        UserLoginCacheDTO sysUser = this.getSysUser();
        return Wrapper.success(channelCommodityService.deleteBatchChannelCommodity(sysUser, simpleIdListRequest.getIdList()));
    }

    /**
     * 删除渠道商品价格--未上架
     * @return
     */
    @RequestMapping(value = "deleteChannelCommodityPrice", method = RequestMethod.POST)
    public Wrapper<String> deleteChannelCommodityPrice(@RequestBody SimpleIdRequest simpleIdRequest){
        return Wrapper.success(channelCommodityService.deleteChannelCommodityPrice(simpleIdRequest));
    }

    /**
     * 获取渠道商品上架商城(单个)
     * @param id 商品id
     * @return
     */
    @RequestMapping(value = "/getShop", method = RequestMethod.GET)
    public Wrapper<List<CommodityShopResponse>> getShop(@RequestParam("id") Long id) {
        List<CommodityShopResponse> resultList = new ArrayList<>();
        //获取商品对应的上架商城
        Map<String, String> shopMap = redisStringUtils.hGetAll(Constants.REDIS_KEY_SHOP, Constants.REDIS_PLATFORM_MANAGE_INDEX);
        //查询该商品上架的商城
        ChannelCommodityMember channelCommodityMember = channelCommodityService.getChannelCommodityMember(id);
        if(channelCommodityMember != null){
            List<ChannelCommodityShop> shopList = channelCommodityMember.getShopList();
            Integer priceType = channelCommodityMember.getChannelCommodity().getCommodity().getPriceType();
            //过滤企业商城和渠道商城，并且为启用的状态
            for (Map.Entry<String, String> entry : shopMap.entrySet()) {
                String value = entry.getValue();
                JSONObject jsonObject = JSONUtil.parseObj(value);
                Long shopId = jsonObject.getLong("id");
                String name = jsonObject.getStr("name");
                String logoUrl = jsonObject.getStr("logoUrl");
                Integer type = jsonObject.getInt("type");
                Integer state = jsonObject.getInt("state");
                Integer environment = jsonObject.getInt("environment");
                if (CommonConstant.State.STATE_START.equals(state)) {
                    //现货和询价的只能在渠道商城/渠道自有商城上架；积分兑换的只能在渠道积分商城上架；
                    if (((PriceTypeEnum.Cash.getCode().equals(priceType) || PriceTypeEnum.Consult.getCode().equals(priceType)) && (ShopTypeEnum.CHANNEL.getCode().equals(type) || ShopTypeEnum.CHANNEL_SELF.getCode().equals(type)))
                            || (PriceTypeEnum.Score.getCode().equals(priceType) && ShopTypeEnum.CHANNEL_SCORE.getCode().equals(type))) {
                        CommodityShopResponse commodityShop = new CommodityShopResponse();
                        commodityShop.setShopId(shopId);
                        commodityShop.setEnvironment(environment);
                        commodityShop.setName(name);
                        commodityShop.setType(type);
                        commodityShop.setLogoUrl(logoUrl);
                        //判断该商品是否已经上架
                        shopList.forEach(s -> {
                            if (s.getShopId() != null && shopId.equals(s.getShopId())) {
                                commodityShop.setIsCheck(true);
                            }
                        });
                        resultList.add(commodityShop);
                    }
                }
            }
            return Wrapper.success(resultList.stream().sorted(Comparator.comparing(CommodityShopResponse::getName)).collect(Collectors.toList()));
        }else{
            throw new BusinessException(ResponseCode.PRODUCT_CHANNEL_COMMODITY_NOT_EXIST);
        }
    }

    /**
     * 上下架渠道商品(单个)
     * @param channelCommodityShopRequest
     * @return
     */
    @RequestMapping(value = "/publishCommodity", method = RequestMethod.POST)
    public Wrapper<String> publishCommodity(@RequestBody ChannelCommodityShopRequest channelCommodityShopRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser();
        return Wrapper.success(channelCommodityService.publishCommodity(sysUser, channelCommodityShopRequest));
    }

    /**
     * 获取渠道商品上架商城(批量)
     * @param priceType 产品定价
     * @return
     */
    @RequestMapping(value = "/getShopBatch", method = RequestMethod.GET)
    public Wrapper<List<CommodityShopResponse>> getShopBatch(@RequestParam("priceType") Integer priceType) {
        List<CommodityShopResponse> resultList = new ArrayList<>();
        //获取商品对应的上架商城
        Map<String, String> shopMap = redisStringUtils.hGetAll(Constants.REDIS_KEY_SHOP, Constants.REDIS_PLATFORM_MANAGE_INDEX);
        //过滤企业商城和渠道商城，并且为启用的状态
        for (Map.Entry<String, String> entry : shopMap.entrySet()) {
            String value = entry.getValue();
            JSONObject jsonObject = JSONUtil.parseObj(value);
            Long shopId = jsonObject.getLong("id");
            String name = jsonObject.getStr("name");
            String logoUrl = jsonObject.getStr("logoUrl");
            Integer type = jsonObject.getInt("type");
            Integer state = jsonObject.getInt("state");
            Integer environment = jsonObject.getInt("environment");
            if (CommonConstant.State.STATE_START.equals(state)) {
                //现货和询价的只能在渠道商城/渠道自有商城上架；积分兑换的只能在渠道积分商城上架；
                if (((PriceTypeEnum.Cash.getCode().equals(priceType) || PriceTypeEnum.Consult.getCode().equals(priceType)) && (ShopTypeEnum.CHANNEL.getCode().equals(type) || ShopTypeEnum.CHANNEL_SELF.getCode().equals(type)))
                        || (PriceTypeEnum.Score.getCode().equals(priceType) && ShopTypeEnum.CHANNEL_SCORE.getCode().equals(type))) {
                    CommodityShopResponse commodityShop = new CommodityShopResponse();
                    commodityShop.setShopId(shopId);
                    commodityShop.setEnvironment(environment);
                    commodityShop.setName(name);
                    commodityShop.setType(type);
                    commodityShop.setLogoUrl(logoUrl);
                    resultList.add(commodityShop);
                }
            }
        }
        return Wrapper.success(resultList.stream().sorted(Comparator.comparing(CommodityShopResponse::getName)).collect(Collectors.toList()));
    }

    /**
     * 上架渠道商品(批量)
     * @param channelCommodityShopListRequest
     * @return
     */
    @RequestMapping(value = "/batchPublishCommodity", method = RequestMethod.POST)
    public Wrapper<String> batchPublishCommodity(@RequestBody ChannelCommodityShopListRequest channelCommodityShopListRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser();
        return Wrapper.success(channelCommodityService.batchPublishCommodity(sysUser, channelCommodityShopListRequest));
    }

    /**
     * 下架渠道商品(批量)
     * @param channelCommodityShopListRequest
     * @return
     */
    @RequestMapping(value = "/batchOffPublishCommodity", method = RequestMethod.POST)
    public Wrapper<String> batchOffPublishCommodity(@RequestBody ChannelCommodityShopListRequest channelCommodityShopListRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser();
        return Wrapper.success(channelCommodityService.batchOffPublishCommodity(sysUser, channelCommodityShopListRequest));
    }
}
